print'Personalplaner Update Prozeduren'
go
print'Version: 2.0.1.12131'
go
 
if not exists (select 1 from PrsVerwaltung where Version = '2.0.1.12131')
begin
	insert into PrsVerwaltung (Version, name, Datum) values ('2.0.1.12131', 'Personalplaner', getdate())
	print 'Version aktualisiert...'
end
go
 

if not exists (select o.name from sysobjects o, syscolumns c where o.name='mandant' and c.name='active' and c.id=o.id)
begin
alter table mandant
   add active  int  not null default 1
end
go

if not exists (select * from Options where typ = 'Style' and wert = 1)
begin
   exec set_options 'Style',1,0,'Dark'
   print 'Options : Style set to Dark'
end
go

if not exists (select 1 from Options where typ = 'DisplayOptions' and wert = 4)
begin
  exec set_options 'DisplayOptions',4,0,'PrsId anzeigen'
  print 'Opetions : DisplayOptions PrsId anzeigen erstellt'
end
go

if not exists (select * from Options where typ = 'DisplayOptions' and wert = 5)
begin
   exec set_options 'DisplayOptions',5,1,'Darstellungs Name'
   print 'Options : Displayname set to 1'
end
go

if not exists (select 1 from Options where typ = 'GeneralOptions' and wert = 1)
begin
   exec set_options 'GeneralOptions',1,0,'Show Database Name'
   print 'Options : Show Database Name set to false'
end
go

if not exists (select * from Options where typ = 'GeneralOptions' and wert = 2)
begin
   exec set_options 'GeneralOptions',2,1,'Delete layout on delete plan'
   print 'Options : Delete layout on delete plan set to 1'
end
go

if not exists (select * from Options where typ = 'GeneralOptions' and wert = 3)
begin
   exec set_options 'GeneralOptions',3,1,'Reset last Layout after deleting a layout'
   print 'Options : Reset last Layout after deleting a layout set to 1'
end
go

update PersonalAbteilung set Status = 2 where Status is null and Bis < GETDATE()
print 'Terminated all Person-Abteilungen'